package com.ruoyi.app;

public class GetCharAscii {
    public static void main(String[] args) {
        System.out.println("累加结果"+SumStrAscii("}}"));
        System.out.println("拼接结果"+spliceStrAscii("}}"));
    }

    public static int SumStrAscii(String str){
        byte[] bytestr = str.getBytes();
        int sum = 0;
        for(int i=0;i<bytestr.length;i++){
            sum += bytestr[i];
        }
        return sum;
    }

    public static String spliceStrAscii(String str){
        byte[] bytestr = str.getBytes();
        String result = "";
        for(int i=0;i<bytestr.length;i++){
            result += bytestr[i];
        }
        return result;
    }

    public static String bytetoString(byte[] bytearray) {
        String result = "";
        char temp;

        int length = bytearray.length;
        for (int i = 0; i < length; i++) {
            temp = (char) bytearray[i];
            result += temp;
        }
        return result;
    }

}
